-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add unit test for CachingConnectionFactory producer/consumer reuse and update azure-servicebus-jms to 2.1.0 #47282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…nFactory behavior Verify that when using CachingConnectionFactory mode, producer and consumer caching is properly configured for reusing MessageProducer and MessageConsumer instances for the same destination. Test covers both standard and premium pricing tiers. Co-authored-by: Netyyyy <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds a unit test to verify that Spring Cloud Azure Service Bus JMS correctly configures CachingConnectionFactory to enable caching of MessageProducer and MessageConsumer instances when the appropriate cache properties are set.
Key Changes:
- Adds parameterized test
cachingConnectionFactoryCachesProducersAndConsumersForSameDestinationcovering bothstandardandpremiumpricing tiers - Verifies that
CachingConnectionFactory.isCacheProducers()andisCacheConsumers()returntruewhen configured with cache properties
|
|
||
| ConnectionFactory connectionFactory = context.getBean(ConnectionFactory.class); | ||
| assertThat(connectionFactory).isInstanceOf(CachingConnectionFactory.class); | ||
|
|
||
| CachingConnectionFactory cachingFactory = (CachingConnectionFactory) connectionFactory; | ||
|
|
Copilot
AI
Nov 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Remove this extra blank line to maintain consistency with the rest of the test file. Other tests in this file do not have blank lines between assertions within the same test method.
| ConnectionFactory connectionFactory = context.getBean(ConnectionFactory.class); | |
| assertThat(connectionFactory).isInstanceOf(CachingConnectionFactory.class); | |
| CachingConnectionFactory cachingFactory = (CachingConnectionFactory) connectionFactory; | |
| ConnectionFactory connectionFactory = context.getBean(ConnectionFactory.class); | |
| assertThat(connectionFactory).isInstanceOf(CachingConnectionFactory.class); | |
| CachingConnectionFactory cachingFactory = (CachingConnectionFactory) connectionFactory; |
| assertThat(connectionFactory).isInstanceOf(CachingConnectionFactory.class); | ||
|
|
||
| CachingConnectionFactory cachingFactory = (CachingConnectionFactory) connectionFactory; | ||
|
|
Copilot
AI
Nov 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Remove this blank line to maintain consistency with the rest of the test file. Other tests in this file do not have blank lines between assertions.
| ConnectionFactory connectionFactory = context.getBean(ConnectionFactory.class); | ||
| assertThat(connectionFactory).isInstanceOf(CachingConnectionFactory.class); | ||
|
|
||
| CachingConnectionFactory cachingFactory = (CachingConnectionFactory) connectionFactory; | ||
|
|
Copilot
AI
Nov 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Simplify bean retrieval and casting. Since line 155 already asserts that a CachingConnectionFactory bean exists, these lines can be simplified to:
CachingConnectionFactory cachingFactory = context.getBean(CachingConnectionFactory.class);This eliminates the intermediate ConnectionFactory variable and the redundant isInstanceOf assertion.
| ConnectionFactory connectionFactory = context.getBean(ConnectionFactory.class); | |
| assertThat(connectionFactory).isInstanceOf(CachingConnectionFactory.class); | |
| CachingConnectionFactory cachingFactory = (CachingConnectionFactory) connectionFactory; | |
| CachingConnectionFactory cachingFactory = context.getBean(CachingConnectionFactory.class); | |
|
@copilot update azure-servicebus-jms verion to 2.1.0 and make sure the ut test reusing the same producer for one dest |
- Updated azure-servicebus-jms version from 2.0.0 to 2.1.0 in: - eng/versioning/external_dependencies.txt - sdk/spring/spring-cloud-azure-autoconfigure/pom.xml - sdk/spring/spring-cloud-azure-starter-servicebus-jms/pom.xml - Simplified test code per review feedback: - Removed unnecessary blank lines - Simplified bean retrieval by getting CachingConnectionFactory directly - Removed unused imports - Test verifies that CachingConnectionFactory caches producers/consumers for the same destination when configured with appropriate properties Co-authored-by: Netyyyy <[email protected]>
Updated azure-servicebus-jms to version 2.1.0 and simplified the test code per review feedback. The test now verifies that Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Description
Adds unit test verifying that Spring Cloud Azure Service Bus JMS correctly configures
CachingConnectionFactoryto cache and reuseMessageProducerandMessageConsumerinstances for the same destination. Also updates theazure-servicebus-jmsdependency to version 2.1.0.Changes
New test:
cachingConnectionFactoryCachesProducersAndConsumersForSameDestinationinServiceBusJmsConnectionFactoryConfigurationTestsisCacheProducers()returnstruewhen cache properties are enabledisCacheConsumers()returnstruewhen cache properties are enabledstandardandpremiumpricing tiersDependency update: Updated
azure-servicebus-jmsfrom 2.0.0 to 2.1.0 in:eng/versioning/external_dependencies.txtsdk/spring/spring-cloud-azure-autoconfigure/pom.xmlsdk/spring/spring-cloud-azure-starter-servicebus-jms/pom.xmlThe test ensures Spring Framework's
CachingConnectionFactorywill cache producers/consumers as documented in CachingConnectionFactory.java#L362 and L427.Fixes #47281
All SDK Contribution checklist:
General Guidelines and Best Practices
Testing Guidelines
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.